<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>HouDun许愿墙</title>
	<link rel="stylesheet" href="./Css/index.css" />
	<script type="text/javascript" src='./Js/jquery-1.7.2.min.js'></script>
	<script type="text/javascript" src='./Js/index.js'></script>       
</head>
<body>
    
	<div id='top'>
		<span id='send'></span>
	</div>
	<div id='main'>
            
            <?php
    include "header.php";
        include "footer.php";

    $sql = "SELECT * FROM  wish";
    $result = $conn->query($sql);

          $arrlist = array();

     if ($result->num_rows > 0) {  
    // 输出每行数据

    while($row = $result->fetch_assoc()) {

        array_push($arrlist, $row);        
    }
 } else {
    echo "0 results";
   }
      $conn->close(); 
    ?>

     <div id="right">
	
   <table border="1">
     <tr>
  <td>序号</td>
     <td>留言者</td>
      <td>留言内容</td>
     <td>留言时间</td>
        <td>操作</td>
   </tr>
    <?php foreach($arrlist as $vo){ ?>
   <tr>
     <td><?php echo $vo['id'];?></td>
    <td><?php echo $vo['username'];?></td>
     <td><?php echo $vo['content'];?></td>
       <td><?php echo $vo['time_at'];?></td>
           <td><span><a>修改</a></span><span><a>删除</a></span></td>
       </tr>
        <?php } ?>
      </table>

          </div>

            
                    <?php
                    include_once "config.php";    

$sql1  = "SELECT * FROM  wish";
$result1 = $conn->query($sql);

$arrlist1 = array();

if ($result->num_rows > 0) {  
    // 输出每行数据
    while($row = $result->fetch_assoc()) {
        array_push($arrlist, $row);        
    }
} else {
    echo "0 results";
}
$conn->close();          
           ?>            
            <?php
            foreach ($arrlist as $vo){
            ?>            
        </div>       
            <dl class='paper a1'>
			<dt>
				<span class='username'><?php  echo $vo['username']; ?></span>
				<span class='num'>No.0000<?php  echo $vo['id']; ?></span>
			</dt>
			<dd class='content'><?php  echo $vo[ 'content']; ?></dd>
			<dd class='bottom'>
				<span class='time'><?php  echo $vo['time_at']; ?></span>
				<a href="" class='close'></>
			</dd>
		</dl>  
            <?php
            }            
            ?>              
</div>
	<div id='send-form'>
		<p class='title'><span>许下你的愿望</span><a href="" id='close'></a></p>
		<form action="handler.php" name='wish' onsubmit="return abc();">
			<p>
				<label for="username">李小洞：</label>
				<input type="text" name='username' id='username'/>
			</p>
			<p>
				<label for="content">天天开心！：(您还可以输入&nbsp;<span id='font-num'>50</span>&nbsp;个字)</label>
				<textarea name="content" id='content'></textarea>
				<div id='phiz'>
					<img src="./Images/phiz/zhuakuang.gif" alt="抓狂" />
					<img src="./Images/phiz/baobao.gif" alt="抱抱" />
					<img src="./Images/phiz/haixiu.gif" alt="害羞" />
					<img src="./Images/phiz/ku.gif" alt="酷" />
					<img src="./Images/phiz/xixi.gif" alt="嘻嘻" />
					<img src="./Images/phiz/taikaixin.gif" alt="太开心" />
					<img src="./Images/phiz/touxiao.gif" alt="偷笑" />
					<img src="./Images/phiz/qian.gif" alt="钱" />
					<img src="./Images/phiz/huaxin.gif" alt="花心" />
					<img src="./Images/phiz/jiyan.gif" alt="挤眼" />
				</div>
			</p>
			<span id='send-btn'></span>
                            <input  type="submit" value="许愿" />
		</form>
	</div>
     <script type="text/javascript">
       $( function abc(){
           $("#send-btn"),click(function()){
            var user = $('input#username');
            var cont = $('#content');
       
            if (user.val()==''){   //user.value
                user.focus();
                return false;
            }          
            if (cont.val()==""){
                cont.focus();
                return false;
            }
            return true;
            
        } 
        var username = user.val();
        var cont ent = cont.val();
        $.post("handler.php",{usernane;usernane,cont ent;cont ent),
            funetion(data){
                data = eval("("+data+")");
                alert(data);
            },
            "json");
            
    });
    });
    </script>
<!--[if IE 6]>
    <script type="text/javascript" src="./Js/iepng.js"></script>
    <script type="text/javascript">
        DD_belatedPNG.fix('#send,#close,.close','background');
    </script>
<![endif]-->
</body>
</html>